<template>
    <!-- <h1>{{ word }}</h1> -->
</template>
<script setup lang="ts" name = "currentTime">
import { onMounted, ref, onUnmounted } from 'vue'
import dayjs from 'dayjs'

let emits = defineEmits(['sendTime'])
//子向父传递参数，用emit
let currentTime = ref()

onMounted(() => { //在同一函数结构内，解决作用域问题
    // let currentTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
    // emits('sendTime', currentTime)
    let timeUpdate = setInterval(() => {
        currentTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
        emits('sendTime', currentTime)
    }, 1000)
})
//父传子：props
//接收方法：defineProps
// defineProps(['word'])
//子传父

</script>
<style scoped></style>